package com.spring.server;

import com.spring.http.Servlet;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author Spring King
 * @date 2021/7/11
 */
public class KingWrapper {

    private String uriPattern;

    private Servlet servlet;

    public KingWrapper(String uriPattern, Servlet servlet) {
        this.uriPattern = uriPattern;
        this.servlet = servlet;
    }

    public String getUriPattern() {
        return uriPattern;
    }

    public void setUriPattern(String uriPattern) {
        this.uriPattern = uriPattern;
    }

    public Servlet getServlet() {
        return servlet;
    }

    public void setServlet(Servlet servlet) {
        this.servlet = servlet;
    }

    public boolean match(String uri) {
        Matcher matcher = Pattern.compile(getUriPattern()).matcher(uri);
        return matcher.find();
    }
}
